<?php
/*
 * Report Alarm*/
function html_script_report_alarm(){
?>
<script type="text/javascript" src="./libs/jquery.min.js"></script>
<script type="text/javascript" src="./libs/jquery-latest.js"></script>
<script type="text/javascript" src="./libs/jquery.highlight-4.js"></script>
<script src="style/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript">
	function getQueryStrings() { 
		  var assoc  = {};
		  var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
		  var queryString = location.search.substring(1); 
		  var keyValues = queryString.split('&'); 
	
		  for(var i in keyValues) { 
		    var key = keyValues[i].split('=');
		    if (key.length > 1) {
		      assoc[decode(key[0])] = decode(key[1]);
		    }
		  } 
		  return assoc; 
		}	
	
</script>

<!-- Script call  device filter, search ---------------> 	 
<script>
function highlight(container,what,spanClass) {
    var content = container.innerHTML,
        pattern = new RegExp('(>[^<.]*)(' + what + ')([^<.]*)','g'),
        replaceWith = '$1<span ' + ( spanClass ? 'class="' + spanClass + '"' : '' ) + '">$2</span>$3',
        highlighted = content.replace(pattern,replaceWith);
    return (container.innerHTML = highlighted) !== content;
}
	$(document).ready(function() {
		$("#id_host_report").change(function(){
		 	//get current selected value of combobox
		 	var shost = $(this).val();
		 	var sgroup =$("#id_group_interface").val();
		 	var presents =$("#id_presets_report").val();
		 	var limit = $("#get_limit").val();
		 	var top = $("#id_top").val();
		 	//build query string
		 	var queryString = "run=report_alarm&shost="+shost+"&sgroup="+sgroup+"&presets="+presents+"&limit="+limit+"&top="+top;
		 	document.location.href = "?"+queryString;
		});
		$("#id_group_interface").change(function(){
		 	//get current selected value of combobox
		 	var sgroup =$(this).val();
		 	var shost = $("#id_host_report").val();
		 	var presents =$("#id_presets_report").val();
		 	var limit = $("#get_limit").val();
		 	var top = $("#id_top").val();
		 	//build query string
		 	var queryString = "run=report_alarm&shost="+shost+"&sgroup="+sgroup+"&presets="+presents+"&limit="+limit+"&top="+top;
		 	document.location.href = "?"+queryString;
		});
		$("#id_host").change(function(){
		 	//get current selected value of combobox
		 	var id = $(this).val();
		 	var sgroup =$("#id_group_interface").val();
		 	var shost = $("#id_host_report").val();
		 	var presents =$("#id_presets_report").val();
		 	var limit = $("#get_limit").val();
		 	var top = $("#id_top").val();
		 	//build query string
		 	var queryString = "run=report_alarm&shost="+shost+"&sgroup="+sgroup+"&id_hs="+id+"&presets="+presents+"&limit="+limit+"&top="+top;
		 	document.location.href = "?"+queryString;
		});
		$("#id_group").change(function(){
		 	//get current selected value of combobox
		 	var id = $(this).val();
		 	var sgroup =$("#id_group_interface").val();
		 	var shost = $("#id_host_report").val();
		 	var presents =$("#id_presets_report").val();
		 	var limit = $("#get_limit").val();
		 	var top = $("#id_top").val();
		 	//build query string
		 	var queryString = "run=report_alarm&shost="+shost+"&sgroup="+sgroup+"&id_gr="+id+"&presets="+presents+"&limit="+limit+"&top="+top;
		 	document.location.href = "?"+queryString;
		});
		$("#id_presets_report").change(function(){
		 	//get current selected value of combobox
		 	var presents = $(this).val();
		 	var sgroup =$("#id_group_interface").val();
		 	var shost = $("#id_host_report").val();
		 	var limit = $("#get_limit").val();
		 	var top = $("#id_top").val();
		 	//build query string
		 	var queryString = "run=report_alarm&shost="+shost+"&sgroup="+sgroup+"&presets="+presents+"&limit="+limit+"&top="+top;
		 	document.location.href = "?"+queryString;
		});
		$("#id_top").change(function(){
		 	//get current selected value of combobox
		 	var top = $(this).val();
		 	var presents = $("#id_presets_report").val();
		 	var sgroup =$("#id_group_interface").val();
		 	var shost = $("#id_host_report").val();
		 	var limit = $("#get_limit").val();
		 	//build query string
		 	var queryString = "run=report_alarm&shost="+shost+"&sgroup="+sgroup+"&presets="+presents+"&limit="+limit+"&top="+top;
		 	document.location.href = "?"+queryString;
		});
		$("#btnGo1"). click(function (){
		 	//get current selected value of combobox
		 	//var LimitValue = $("id_limit_report").val();
		 	var sgroup =$("#id_group_interface").val();
		 	var shost = $("#id_host_report").val();
		 	var presents =$("#id_presets_report").val();
		 	var date_from = $("#date1").val();
		 	var date_to = $("#date2").val();
		 	var limit = $("#get_limit").val();
		 	var top = $("#id_top").val();
		 	//build query string
		 	var queryString = "run=report_alarm&shost="+shost+"&sgroup="+sgroup+"&presets="+presents+"&datefrom="+date_from+"&dateto="+date_to+"&limit="+limit+"&top="+top+"&export=interface";
		 	document.location.href = "?"+queryString;
		});
		 $("#btnClear1"). click(function (){
			 	var sgroup ='';
			 	var shost = '';
			 	var presents ='';
			 	var limit = '1';
			 	var top = '';	
			 	var queryString = "run=report_alarm&shost="+shost+"&sgroup="+sgroup+"&presets="+presents+"&limit="+limit+"&top="+top;
			 	document.location.href = "?"+queryString;
		 });
	/*Button Refresh change event*/
		 $("#btnRefresh"). click(function (){
				window.location.reload();
				history.go(0);
				window.location.href = window.location.href;
		 });
	});
</script>
<?php 
}
function html_reload_report_alarm(){
?>
	<script>
		function reLoad1(){
			var sgroup =$("#id_group_interface").val();
			var shost = $("#id_host_report").val();
			queryString = "run=group&run=report_alarm&shost="+shost+"&sgroup="+sgroup;
			window.location.href = "?"+queryString;
		}
	</script>
<?php 
}
?>